<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::prefix('v1')->name('api.v1.')->group(function () {

    Route::get('test', 'TestController@index')->name('test.index');

    Route::namespace('User')->group(function () {
        Route::get('wx_pay_notify', 'PayController@wxPayNotify')->name('pau.wxPayNotify');
        Route::post('wx_pay_notify', 'PayController@wxPayNotify')->name('pau.wxPayNotify');
    });

    Route::middleware('throttle:' . config('api.rate_limits.sign'))->group(function () {
        Route::prefix('auth')->group(function () {
            Route::post('login', 'AuthController@login')->name('auth.login');
            Route::post('phone_login', 'AuthController@phoneLogin')->name('auth.phoneLogin');
            Route::post('wx_login', 'AuthController@wxLogin')->name('auth.wxLogin');
            Route::post('register', 'AuthController@register')->name('auth.register');
            Route::post('forget', 'AuthController@forget')->name('auth.forget');
            Route::post('phone_code', 'IndexController@phoneCode')->name('index.phoneCode');
            Route::post('mail_code', 'IndexController@mailCode')->name('index.mailCode');
        });
        Route::prefix('index')->group(function () {
            Route::get('index', 'IndexController@index')->name('index.index');
            Route::get('countries', 'IndexController@countries')->name('index.countries');
            Route::middleware('auth:sanctum')->group(function () {
                Route::get('index_auth', 'IndexController@indexAuth')->name('index.indexAuth');
                Route::post('upload', 'IndexController@upload')->name('index.update');
            });
        });

        Route::middleware('auth:sanctum')->prefix('auth')->group(function () {
            Route::post('bind_phone', 'AuthController@bindPhone')->name('index.bindPhone');
            Route::post('bind_mail', 'AuthController@bindMail')->name('index.bindMail');
            Route::post('loginout', 'AuthController@loginOut')->name('auth.loginOut');
            Route::post('update_userinfo', 'AuthController@updateUserInfo')->name('auth.updateUserInfo');
            Route::post('upload', 'IndexController@upload')->name('index.update');
        });

        Route::prefix('article')->namespace('Article')->group(function () {
            Route::get('article', 'ArticleController@index')->name('article.index');
            Route::get('article/{id}', 'ArticleController@view')->name('article.view');
        });

        Route::prefix('forwarder')->namespace('Forwarder')->group(function () {
            Route::get('forwarder', 'ForwarderController@index')->name('forwarder.index');

            Route::middleware('auth:sanctum')->group(function () {
                Route::get('index', 'ForwarderController@details')->name('forwarder.details');
                Route::get('check_apply', 'ForwarderController@checkApply')->name('forwarder.checkApply');
                Route::get('forwarder/{id}', 'ForwarderController@view')->name('forwarder.view');
                Route::post('forwarder', 'ForwarderController@store')->name('forwarder.store');
                Route::post('forwarder/{id}', 'ForwarderController@update')->name('forwarder.update');

                Route::get('forwarder_line_select', 'ForwarderLineController@selectData')->name('forwarder_line.selectData');
                Route::get('forwarder_line', 'ForwarderLineController@index')->name('forwarder_line.index');
                Route::get('forwarder_line/{id}', 'ForwarderLineController@view')->name('forwarder_line.view');
                Route::post('forwarder_line', 'ForwarderLineController@store')->name('forwarder_line.store');
                Route::post('forwarder_line/{id}', 'ForwarderLineController@update')->name('forwarder_line.update');
                Route::delete('forwarder_line/{id}', 'ForwarderLineController@destroy')->name('forwarder_line.destroy');

                Route::get('forwarder_line_cost', 'ForwarderLineCostController@index')->name('forwarder_line_cost.index');
                Route::get('forwarder_line_cost/{id}', 'ForwarderLineCostController@view')->name('forwarder_line_cost.view');
                Route::post('forwarder_line_cost', 'ForwarderLineCostController@store')->name('forwarder_line_cost.store');
                Route::post('forwarder_line_cost/{id}', 'ForwarderLineCostController@update')->name('forwarder_line_cost.update');
                Route::delete('forwarder_line_cost/{id}', 'ForwarderLineCostController@destroy')->name('forwarder_line_cost.destroy');

                Route::get('forwarder_line_cost_other/{id}', 'ForwarderLineCostOtherController@view')->name('forwarder_line_cost_other.view');
                Route::post('forwarder_line_cost_other', 'ForwarderLineCostOtherController@store')->name('forwarder_line_cost_other.store');
                Route::post('forwarder_line_cost_other/{id}', 'ForwarderLineCostOtherController@update')->name('forwarder_line_cost_other.update');
                Route::delete('forwarder_line_cost_other/{id}', 'ForwarderLineCostOtherController@destroy')->name('forwarder_line_cost_other.destroy');


                Route::get('badge/{id}', 'BadgeController@view')->name('badge.view');
                Route::get('badge_user', 'BadgeUserController@index')->name('badge_user.index');
                Route::post('badge_user/{id}', 'BadgeUserController@update')->name('badge_user.update');

                Route::get('follow', 'ForwarderFollowController@index')->name('follow.index');
                Route::post('follow', 'ForwarderFollowController@store')->name('follow.store');
                Route::delete('follow/{id}', 'ForwarderFollowController@destroy')->name('follow.destroy');

                Route::get('forwarder_contact', 'ForwarderContactController@index')->name('forwarder_contact.index');
                Route::get('forwarder_contact/{id}', 'ForwarderContactController@view')->name('forwarder_contact.view');
                Route::post('forwarder_contact', 'ForwarderContactController@store')->name('forwarder_contact.store');
                Route::post('forwarder_contact/{id}', 'ForwarderContactController@update')->name('forwarder_contact.update');
                Route::delete('forwarder_contact/{id}', 'ForwarderContactController@destroy')->name('forwarder_contact.destroy');

                Route::get('forwarder_store', 'ForwarderStoreController@index')->name('forwarderStore.index');
                Route::get('forwarder_store/{id}', 'ForwarderStoreController@view')->name('forwarderStore.view');
                Route::post('forwarder_store', 'ForwarderStoreController@store')->name('forwarderStore.store');
                Route::post('forwarder_store/{id}', 'ForwarderStoreController@update')->name('forwarderStore.update');
                Route::delete('forwarder_store/{id}', 'ForwarderStoreController@destroy')->name('forwarderStore.destroy');

                Route::get('forwarder_complain', 'ForwarderComplainController@index')->name('forwarder_complain.index');
                Route::post('forwarder_complain', 'ForwarderComplainController@store')->name('forwarder_complain.store');
                Route::post('forwarder_complain/{id}', 'ForwarderComplainController@update')->name('forwarder_complain.update');

                Route::get('forwarder_comment', 'ForwarderCommentController@index')->name('forwarder_comment.index');
                Route::post('forwarder_comment', 'ForwarderCommentController@store')->name('forwarder_comment.store');

                Route::get('forwarder_line_comment', 'ForwarderLineCommentController@index')->name('forwarder_line_comment.index');
                Route::post('forwarder_line_comment', 'ForwarderLineCommentController@store')->name('forwarder_line_comment.store');

                Route::get('coupon', 'CouponController@index')->name('coupon.index');
                Route::get('coupon_user', 'CouponController@couponUser')->name('coupon.couponUser');
                Route::get('coupon/{id}', 'CouponController@view')->name('coupon.view');
                Route::post('coupon', 'CouponController@store')->name('coupon.store');
                Route::post('coupon/{id}', 'CouponController@update')->name('coupon.update');
                Route::delete('coupon/{id}', 'CouponController@destroy')->name('coupon.destroy');
                Route::post('coupon_award/{id}', 'CouponController@award')->name('coupon.award');
            });

        });

        Route::middleware('auth:sanctum')->prefix('order')->namespace('Order')->group(function () {
            Route::get('order', 'OrderController@index')->name('order.index');
            Route::get('order/{id}', 'OrderController@view')->name('order.view');
            Route::post('order', 'OrderController@store')->name('order.store');

            Route::post('take', 'OrderController@take')->name('order.take');
            Route::post('cancel', 'OrderController@cancel')->name('order.cancel');
            Route::post('confirm', 'OrderController@confirm')->name('order.confirm');

            Route::get('preset', 'OrderPresetController@index')->name('preset.index');
            Route::post('preset', 'OrderPresetController@store')->name('preset.store');
            Route::post('preset/{id}', 'OrderPresetController@update')->name('preset.update');
            Route::delete('preset/{id}', 'OrderPresetController@destroy')->name('preset.destroy');
        });

        Route::middleware('auth:sanctum')->prefix('user')->namespace('User')->group(function () {
            Route::get('address', 'AddressController@index')->name('address.index');
            Route::get('address/{id}', 'AddressController@view')->name('address.view');
            Route::post('address', 'AddressController@store')->name('address.store');
            Route::post('address/{id}', 'AddressController@update')->name('address.update');
            Route::delete('address/{id}', 'AddressController@destroy')->name('address.destroy');

            Route::get('account', 'AccountController@index')->name('account.index');
            Route::get('account_fund', 'AccountFundController@index')->name('account_fund.index');

            Route::post('wx_pay', 'PayController@wxPay')->name('pay.index');
            Route::post('check_pay', 'PayController@checkPay')->name('pay.index');

        });

        Route::middleware('auth:sanctum')->prefix('chat')->namespace('Chat')->group(function () {
            Route::get('room', 'ChatRoomController@index')->name('chat_room.index');
            Route::post('room', 'ChatRoomController@store')->name('chat_room.store');

            Route::get('message', 'ChatMessageController@index')->name('chat_message.index');
            Route::post('message', 'ChatMessageController@store')->name('chat_message.store');
        });

        Route::middleware('auth:sanctum')->prefix('subject')->namespace('Subject')->group(function () {
            Route::get('index', 'SubjectController@details')->name('subject.details');
            Route::get('subject', 'SubjectController@index')->name('subject.index');
            Route::get('subject_self', 'SubjectController@subjectSelf')->name('subjectSelf.index');
            Route::get('subject/{id}', 'SubjectController@view')->name('subject.view');
            Route::post('subject', 'SubjectController@store')->name('subject.store');
            Route::post('subject/{id}', 'SubjectController@update')->name('subject.update');
            Route::delete('subject/{id}', 'SubjectController@destroy')->name('subject.destroy');
            Route::post('face/{id}', 'SubjectController@face')->name('subject.face');

            Route::get('subject_user', 'SubjectUserController@index')->name('subject_user.index');
            Route::get('subject_users', 'SubjectUserController@user')->name('subject_user.user');
            Route::post('subject_user', 'SubjectUserController@store')->name('subject_user.store');
            Route::post('subject_user/{id}', 'SubjectUserController@update')->name('subject_user.update');
            Route::delete('subject_user/{id}', 'SubjectUserController@destroy')->name('subject_user.destroy');
        });

        Route::middleware('auth:sanctum')->prefix('dict')->group(function () {
            Route::get('configs', 'DictController@configs')->name('dict.configs');
            Route::get('countrys', 'DictController@countrys')->name('dict.countrys');
            Route::get('harbours', 'DictController@harbours')->name('dict.harbours');
            Route::get('ships', 'DictController@ships')->name('dict.ships');
            Route::get('airlines', 'DictController@airlines')->name('dict.airlines');
            Route::get('airports', 'DictController@airports')->name('dict.airports');
            Route::get('fba_storage', 'DictController@fba_storage')->name('dict.fba_storage');
            Route::get('express', 'DictController@express')->name('dict.express');
            Route::get('abroad_country', 'DictController@abroadCountry')->name('dict.abroadCountry');
            Route::get('world_city', 'DictController@worldCity')->name('dict.worldCity');
        });

        Route::middleware('auth:sanctum')->prefix('message')->namespace('Message')->group(function () {
            Route::get('message', 'MessageController@index')->name('message.index');
        });

    });
});
